package com.zpark.common;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * 项目前后端交互的设计类 —— 统一的返回形式
 */
@Getter
@Setter
@AllArgsConstructor
public class R<T> { // 10001 10002
    private String code;
    private String message;
    private T data;
    public static <T>R ok(T data){
        return  new R<T>("20000","访问成功了",data);
    }
    public static <T>R ok(T data,String message){
        return  new R<T>("20000",message,data);
    }

    public static <T>R ok(String message){
        return  new R<T>("20000",message,null);
    }

    public static <T>R error(String message){
        return  new R<T>("50000",message,null);
    }
}
